<template>
  <div class="app-container">
    <div class="background-color: #fff;">
      <!-- 查询 -->
      <div class="filter-container">
        <el-form :inline="true" class="search-form" label-width="100px">
          <el-row style="display: flex; flex-wrap: wrap">
            <div style="flex: 1">
              <el-form-item label="用户id" style="margin: 5px 0">
                <el-input v-model="searchForm.user_id" placeholder="请输入用户ID" clearable style="width: 260px"
                  show-word-limit />
              </el-form-item>
              <el-form-item label="实名姓名" style="margin: 5px 0">
                <el-input v-model="searchForm.name" placeholder="请输入实名姓名" clearable style="width: 260px"
                  show-word-limit />
              </el-form-item>
              <el-form-item v-if="searchDisplay" label="审核类型" style="margin: 5px 0">
                <el-select v-model="searchForm.audit_type" placeholder="请选择审核类型">
                  <el-option v-for="item in auditTypeList" :key="item.id" :label="item.name" style="width: 260px"
                    :value="item.id" />
                </el-select>
              </el-form-item>
              <el-form-item v-if="searchDisplay" label="审核状态" style="margin: 5px 0">
                <el-select v-model="searchForm.status" style="width: 260px" placeholder="请选择审核状态">
                  <el-option v-for="item in statusList" :key="item.id" :label="item.name" style="width: 260px"
                    :value="item.id" />
                </el-select>
              </el-form-item>
            </div>
            <div style="padding: 5px 0">
              <el-form-item>
                <el-button type="primary" icon="el-icon-search" @click="getQuery">查询</el-button>
                <el-button type="primary" icon="el-icon-refresh" @click="resettingWay">重置</el-button>
                <el-button v-if="!searchDisplay" type="warning" icon="el-icon-caret-bottom"
                  @click="searchDisplay = true">展开</el-button>
                <el-button v-else type="warning" icon="el-icon-caret-top" @click="searchDisplay = false">收起</el-button>
              </el-form-item>
            </div>
          </el-row>
        </el-form>
      </div>
    </div>
    <el-divider />
    <div class="grouping" style="margin-top: 20px;padding: 0 20px 20px;">
      <div class="marginBottom">
        <el-row :gutter="20" style="display: flex">
          <el-col>
            <!-- <el-button type="primary" size="small" icon="el-icon-download"
              @click="addGoodsWay()">批量导出</el-button> -->
          </el-col>
          <el-col :span="8" style="float: right">
            <div class="right-panel el-button-group">
              <el-button icon="el-icon-refresh" size="mini" @click="resettingWay" />
              <el-dropdown trigger="click" :hide-on-click="false">
                <span class="el-dropdown-link">
                  <el-button icon="el-icon-s-operation" size="mini" />
                </span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item v-for="fruit in allTableThead" :key="fruit">
                    <el-checkbox v-model="checkboxTableThead" :label="fruit">{{
                      tableTheadOptions[fruit].label
                    }}</el-checkbox>
                  </el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </div>
          </el-col>
        </el-row>
      </div>
      <el-row :gutter="20">
        <el-col>
          <el-table v-loading="loading" :data="GoodsLists" :header-cell-style="{
              'background-color': '#f3f8fe',
              color: '#606266',
              height: '50px',
            }" style="width: 100%">
            <el-table-column v-for="fruit in tableThead" :key="fruit" :label="tableTheadOptions[fruit].label"
              align="center">
              <template slot-scope="scope">
                <div v-if="fruit == 'main_image'">
                  <div style="width: 40px; height: 40px; margin: 0 auto">
                    <el-image v-if="scope.row.main_image" :src="scope.row.main_image"
                      :preview-src-list="[scope.row.main_image]" />
                  </div>
                </div>
                <div v-else-if="fruit == 'id_card_front_photo'">
                  <div style="width: 40px; height: 40px; margin: 0 auto">
                    <el-image v-if="scope.row.id_card_front_photo" :src="scope.row.id_card_front_photo"
                      :preview-src-list="[scope.row.id_card_front_photo]" />
                  </div>
                </div>
                <div v-else-if="fruit == 'id_card_back_photo'">
                  <div style="width: 40px; height: 40px; margin: 0 auto">
                    <el-image v-if="scope.row.id_card_back_photo" :src="scope.row.id_card_back_photo"
                      :preview-src-list="[scope.row.id_card_back_photo]" />
                  </div>
                </div>
                <div v-else-if="fruit == 'status'">
                  <span style="color: #0076f6;" v-if="scope.row.status == 0">待审核</span>
                  <span style="color: #13ce66;" v-if="scope.row.status == 1">审核通过</span>
                  <span style="color: #f86d60;" v-if="scope.row.status == 2">审核驳回</span>
                </div>
                <div v-else-if="fruit == 'audit_type'">
                  <span v-if="scope.row.audit_type == 1">人工审核</span>
                  <span v-else>系统审核</span>
                </div>
                <div v-else>
                  <el-tooltip placement="top-start" :content="scope.row[fruit] + ''">
                    <div class="one_line_hidden">
                      {{ scope.row[fruit] ? scope.row[fruit] : "-" }}
                    </div>
                  </el-tooltip>
                </div>
              </template>
            </el-table-column>
            <el-table-column align="center" fixed="right" width="200" prop="address" label="操作">
              <template slot-scope="scope">
                <el-button v-if="scope.row.status==0" type="text" @click="setAudit(scope.row)">
                  审核
                </el-button>
                <el-button type="text" @click="Ramedetail(scope.row)">
                  详情
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-col>
        <el-col class="marginTop" style="text-align: right">
          <el-pagination :current-page="page" :page-sizes="[10, 20, 30, 40]" :page-size="count"
            layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
            @current-change="handleCurrentChange" />
        </el-col>
      </el-row>
    </div>
    <audit-record ref="refRecord" @getQuery="getQuery" />
    <audit-detail ref="refDetail" :realname_details="realname_details" />
  </div>
</template>

<script>
  import {
    getUserList
  } from '@/api/userAttestation/index'
  import AuditRecord from './components/auditRecord.vue'
  import AuditDetail from './components/auditDetail.vue'
  const tableTheadOption = {
    user_id: {
      label: '用户ID',
      field: 'user_id'
    },
    name: {
      label: '实名姓名',
      field: 'name'
    },
    id_card_no: {
      label: '证件号',
      field: 'id_card_no'
    },
    end_time: {
      label: '有效期限',
      field: 'end_time'
    },
    residence_address: {
      label: '联系地址',
      field: 'residence_address'
    },
    id_card_front_photo: {
      label: '身份证-正',
      field: 'id_card_front_photo'
    },
    id_card_back_photo: {
      label: '身份证-反',
      field: 'id_card_back_photo'
    },
    status: {
      label: '审核状态',
      field: 'status'
    },
    audit_type: { // 审核类型 1人工审核 2系统审核
      label: '审核类型',
      field: 'audit_type'
    },
    admin_id: {
      label: '审核人员',
      field: 'admin_id'
    },
    audit_time: {
      label: '审核时间',
      field: 'bn'
    },
    created_at: {
      label: '审核时间',
      field: 'created_at'
    },
    remarks: {
      label: '审核说明',
      field: 'remarks'
    }
  }
  const allTableThead = ['user_id', 'name', 'id_card_no', 'residence_address', 'id_card_front_photo',
    'id_card_back_photo', 'status',
    'audit_type', 'admin_id', 'audit_time', 'remarks', 'created_at'
  ]
  const defaultTableThead = ['user_id', 'name', 'id_card_no', 'residence_address', 'status',
    'audit_type', 'admin_id', 'audit_time',"remarks"
  ]
  export default {
    components: {
      AuditRecord,
      AuditDetail
    },
    data() {
      return {
        realname_details:{},//实名详情
        kucunmer_id: {},
        // 当前搜索是否展开
        searchDisplay: false,
        // 动态显示表头默认表头
        tableTheadOptions: tableTheadOption,
        allTableThead: allTableThead,
        tableThead: defaultTableThead, // 默认表头
        checkboxTableThead: defaultTableThead, // 默认表头值
        tableKey: 1, // 为了保证table 每次都会重渲
        // 商品列表加载框
        loading: false,
        // 商品列表
        GoodsLists: [],
        // 商品列表总条数
        total: 0,
        auditTypeList: [{
            id: 1,
            name: '人工审核'
          },
          {
            id: 2,
            name: '系统审核'
          }
        ], //
        statusList: [{
            id: 0,
            name: '待审核'
          },
          {
            id: 1,
            name: '审核通过'
          },
          {
            id: 2,
            name: '审核驳回'
          }
        ],
        // 商品标签列表
        labelList: [],
        // 供应商商品列表
        goodsList: [],
        // 商品单位列表
        unitList: [],
        // 支付类型列表
        payTypeList: [],
        // 商品类型区分列表
        distinguishList: [],
        // 用户分组列表
        userGroupList: [],
        // 省市区列表
        regionList: [],
        // 搜搜参数
        searchForm: {
          user_id: '',
          name: '',
          audit_type: '',
          status: ''
        },
        page: 1,
        count: 10,
        multipleSelection: [], // 当前选中的列表
      }
    },
    watch: {
      checkboxTableThead(valArr) {
        this.tableThead = this.allTableThead.filter(
          (i) => valArr.indexOf(i) >= 0
        )
        this.tableKey = this.tableKey + 1
      }
    },
    created() {
      this.getListWay()
    },
    methods: {
      // 列表选中
      handleSelectionChange(val) {
        this.multipleSelection = val
      },
      //批量导出
      addGoodsWay(){
        if(this.multipleSelection.length > 0){

        }else{
          this.$messages.success('请至少选择一项')
        }
      },
      //详情
      Ramedetail(row) {
        this.realname_details = row
        this.$refs.refDetail.open()
      },
      tabsListWay() {
        this.page = 1
        this.count = 10
        this.getListWay()
      },
      getQuery() {
        this.page = 1
        this.getListWay()
      },
      // 获取商品列表
      getListWay() {
        this.loading = true
        getUserList({
            page: this.page,
            count: this.count,
            search: {
              ...this.searchForm
            }
          })
          .then((res) => {
            this.loading = false
            if (res.code !== 200 || res.status !== 1) {
              this.$messages.error(res.msg)
              return
            }
            this.GoodsLists = res.data.list
            this.total = res.data.total
          })
          .catch(() => {
            this.loading = false
          })
      },
      // 重置搜索条件
      resettingWay() {
        this.searchForm = {
          user_id: '',
          name: '',
          audit_type: '',
          status: ''
        }
        this.page = 1
        this.count = 10
        this.getListWay()
      },
      // 点击搜索
      search() {},

      // 分页选择调用
      handleSizeChange(val) {
        this.count = val
        this.getListWay()
      },
      // 分页选择调用
      handleCurrentChange(val) {
        this.page = val
        this.getListWay()
      },
      //   审核
      setAudit(row) {
        this.$refs.refRecord.ruleForm.id = row.id
        this.$refs.refRecord.open()
      }
    }
  }
</script>

<style lang="scss" scoped>
  .title {
    color: rgba(0, 0, 0, 0.85);
    font-weight: 500;
    font-size: 16px;
    line-height: 16px;
  }

  .sn {
    color: #606266;
    font-size: 13px;
  }

  .goodsaletr {
    border-radius: 5px;
    background-color: #f0faff;
    border: 1px solid #abdcff;
    color: #515a6e;
    font-size: 12px !important;
  }

  .demo-table-expand {
    display: flex;
    justify-content: start;
    flex-wrap: wrap;
    color: #515a6e;

    div {
      width: 30%;
      height: 40px;
      text-align: center;
      line-height: 40px;
      font-size: 12px;
    }
  }

  .marginTop {
    padding: 0 15px !important;
  }
</style>
<style>
  .el-upload--picture-card {
    width: 90px !important;
    height: 90px !important;
    line-height: 90px;
  }

  .el-upload-list--picture-card .el-upload-list__item-actions {
    width: 90px !important;
    height: 90px !important;
  }

  .el-upload-list--picture-card .el-upload-list__item-thumbnail {
    width: 90px !important;
    height: 90px !important;
  }

  .el-upload-list--picture-card .el-upload-list__item {
    width: 90px !important;
    height: 90px !important;
  }

  .tox .tox-dialog-wrap__backdrop {
    z-index: 9993 !important;
  }

  .tox-tinymce-aux {
    z-index: 9990 !important;
  }

  .tox .tox-dialog {
    z-index: 9995 !important;
  }
</style>
<style lang="scss" scoped>
  .phone {
    position: relative;
    margin-left: 50%;
    width: 380px;
    height: 800px;
    border: 5px solid #949494;
    border-radius: 40px;
    transform: scale(0.8) translateY(-50px);
  }

  .phone:before {
    content: "";
    position: absolute;
    width: 369px;
    height: 789px;
    // box-shadow: 0px 0px 24px #000;
    background-color: #000;
    border-radius: 33px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .phone:after {
    content: "";
    position: absolute;
    width: 364px;
    height: 786px;
    background: #fff;
    border-radius: 28px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .html {
    position: absolute;
    width: 364px - 5px - 5px;
    height: 786px - 5px - 5px;
    background: #fff;
    border-radius: 30px;
    overflow: hidden;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 5px;
    z-index: 1;
  }

  .receiver {
    position: absolute;
    top: 5px;
    left: 50%;
    margin-left: -50px;
    background: #000000;
    border: #484848 1px solid;
    width: 100px;
    height: 8px;
    z-index: 9;
    border-radius: 20px;
  }

  .receiver ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    margin: 1px;
    justify-content: space-around;
  }

  .receiver ul li {
    background: #303030;
    width: 1px;
    height: 1.5px;
    float: left;
    transform: skewX(-38deg);
  }

  .receiver div {
    width: 100px;
    height: 8px;
  }

  .receiver div:after {
    content: "";
    display: block;
    width: 95%;
    height: 83%;
    top: 1px;
    left: 3px;
    position: absolute;
    background-repeat: no-repeat;
    background-image: repeating-linear-gradient(to right,
        #434242,
        #000000 1px,
        rgba(255, 255, 255, 0) 1px,
        rgba(255, 255, 255, 0) 3px),
      repeating-linear-gradient(to right,
        #434242,
        #19191d 1px,
        rgba(255, 255, 255, 0) 1px,
        rgba(255, 255, 255, 0) 3px);
    background-size: 100% 50%;
    background-position: 0 0, 2px 4px;
    transform: skew(-25deg);
  }

  .labelView {
    width: 150px;
  }

  .infoDiv {
    display: flex;
    // align-items: center;
    background-color: #F5F5F5;
    border-radius: 6px;
    padding: 10px;
    margin-top: 10px;
    margin-bottom: 10px;

    .img {
      width: 65px;
      height: 65px;
      border-radius: 50%;
      background-color: #fff;
    }

    .right {}

    .scenter {
      flex: 1;
      margin-left: 10px;

      h3 {
        line-height: 30px;
        font-weight: 400;
        font-size: 16px;
        padding: 0px 0;
        margin: 0;
      }
    }
  }

  .orderdetail_item {
    display: flex;
    align-items: center;
    // width: 165px;
    justify-content: start;
    margin-right: 30px;

    p:nth-child(2) {
      color: #000;
      font-weight: 550;
      margin-left: 15px;
    }
  }

  .order_center {
    display: flex;
    align-items: center;
    justify-content: start;
    flex-wrap: wrap;
    padding: 0 2px 0 0;
    font-size: 13px;
    color: #666;
  }
</style>
